package com.example.bookmanagement.exception;

import com.example.bookmanagement.common.AjaxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public AjaxResponse<String> handleRuntimeException(RuntimeException e) {
        log.error("异常信息: {}", e.getMessage());
        return AjaxResponse.error(e.getMessage());
    }
}    